}
}
+static void
+portal_error_handler (GtkFileChooserNative *self)
+{
+ self->mode = MODE_FALLBACK;
+ show_dialog (self);
+}
+
static void
gtk_file_chooser_native_show (GtkNativeDialog *native)
{
#endif
if (self->mode == MODE_FALLBACK &&
- gtk_file_chooser_native_portal_show (self))
+ gtk_file_chooser_native_portal_show (self, portal_error_handler))
self->mode = MODE_PORTAL;
if (self->mode == MODE_FALLBACK)
#include "gtkfilefilterprivate.h"
#include "gtkwindowprivate.h"
+
typedef struct {
GtkFileChooserNative *self;
const char *method_name;
GtkWindow *exported_window;
+ PortalErrorHandler error_handler;
} FilechooserPortalData;
if (reply == NULL)
{
- if (!data->hidden)
- _gtk_native_dialog_emit_response (GTK_NATIVE_DIALOG (self), GTK_RESPONSE_DELETE_EVENT);
- g_warning ("Can't open portal file chooser: %s", error->message);
+ if (!data->hidden && data->error_handler)
+ {
+ data->error_handler (self);
+ filechooser_portal_data_free (data);
+ self->mode_data = NULL;
+ }
g_error_free (error);
- filechooser_portal_data_free (data);
- self->mode_data = NULL;
return;
}
}
gboolean
-gtk_file_chooser_native_portal_show (GtkFileChooserNative *self)
+gtk_file_chooser_native_portal_show (GtkFileChooserNative *self,
+ PortalErrorHandler error_handler)
{
FilechooserPortalData *data;
GtkWindow *transient_for;
data = g_new0 (FilechooserPortalData, 1);
data->self = g_object_ref (self);
data->connection = connection;
+ data->error_handler = error_handler;
data->method_name = method_name;
data->hidden = TRUE;
if (data->portal_handle)
- {
- send_close (data);
- filechooser_portal_data_free (data);
- }
+ send_close (data);
+
+ filechooser_portal_data_free (data);
self->mode_data = NULL;
}
gboolean gtk_file_chooser_native_quartz_show (GtkFileChooserNative *self);
void gtk_file_chooser_native_quartz_hide (GtkFileChooserNative *self);
-gboolean gtk_file_chooser_native_portal_show (GtkFileChooserNative *self);
+typedef void (* PortalErrorHandler) (GtkFileChooserNative *self);
+gboolean gtk_file_chooser_native_portal_show (GtkFileChooserNative *self,
+ PortalErrorHandler error_handler);
void gtk_file_chooser_native_portal_hide (GtkFileChooserNative *self);
G_END_DECLS